package com.yh.workbill.utils;

import com.yh.workbill.model.WorkBill;

import java.util.List;

import androidx.recyclerview.widget.DiffUtil;

public class DiffWorBillCallBack extends DiffUtil.Callback {

    private List<WorkBill> newlist;
    private List<WorkBill> oldlist;

    public DiffWorBillCallBack(List<WorkBill> newlist, List<WorkBill> oldlist) {
        this.newlist = newlist;
        this.oldlist = oldlist;
    }

    @Override
    public int getOldListSize() {
        return oldlist.size();
    }

    @Override
    public int getNewListSize() {
        return newlist.size();
    }

    @Override
    public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
        return oldlist.get(oldItemPosition).getUuid().equals(newlist.get(newItemPosition).getUuid());
    }

    @Override
    public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
        return oldlist.get(oldItemPosition).getUuid().equals(newlist.get(newItemPosition).getUuid())
                && oldlist.get(oldItemPosition).getCompany_name().equals(newlist.get(newItemPosition).getCompany_name())
                && oldlist.get(oldItemPosition).getWork_unit().equals(newlist.get(newItemPosition).getWork_unit())
                && oldlist.get(oldItemPosition).getWork_time().equals(newlist.get(newItemPosition).getWork_time())
                && oldlist.get(oldItemPosition).getWork_device().equals(newlist.get(newItemPosition).getWork_device())
                && oldlist.get(oldItemPosition).getWork_content().equals(newlist.get(newItemPosition).getWork_content())
                && oldlist.get(oldItemPosition).getWork_car_number().equals(newlist.get(newItemPosition).getWork_car_number())
                && oldlist.get(oldItemPosition).getWork_use_time() == newlist.get(newItemPosition).getWork_use_time()
                && oldlist.get(oldItemPosition).getWork_money() == newlist.get(newItemPosition).getWork_money();
    }
}
